package yawning.mew.character;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public enum Clazz {
	WARRIOR("Warrior", 1, 4),
	PALADIN("Paladin", 2, 4),
	HUNTER("Hunter", 3, 3),
	ROGUE("Rogue", 4, 2),
	PRIEST("Priest", 5, 1),
	DEATH_KNIGHT("Death Knight", 6, 4),
	SHAMAN("Shaman", 7, 3),
	MAGE("Mage", 8, 1),
	WARLOCK("Warlock", 9, 1),
	DRUID("Druid", 11, 2);

	public static Clazz get(String name) {
		return valueOf(name.toUpperCase().replace(' ', '_'));
	}

	public static Clazz get(int i) {
		if (sClazzMap.size() == 0) {
			synchronized (sClazzMap) {
				if (sClazzMap.size() == 0) {
					for (Clazz c : values()) sClazzMap.put(c.mCid, c);
				}
			}
		}
		return sClazzMap.get(i);
	}

	@Override
	public String toString() {
		return mName;
	}

	public final TalentTree[] getTalentTrees() {
		if (mTrees == null) Talent.loadTalents();
		return mTrees.toArray(new TalentTree[0]);
	}

	public final Talent[] getTalents() {
		if (mTalents == null) Talent.loadTalents();
		return mTalents.toArray(new Talent[0]);
	}

	public final Glyph[] getGlyphs() {
		return Glyph.getForClass(this);
	}

	private Clazz(String name, int cid, int armorSubclass) {
		mName = name;
		mCid = cid;
		mArmorSubclass = armorSubclass;
	}

	private String mName;
	int mCid;
	int mArmorSubclass;
	List<TalentTree> mTrees;
	List<Talent> mTalents;

	private static Map<Integer,Clazz> sClazzMap = new HashMap<Integer,Clazz>();
}
